cmake_minimum_required(VERSION 3.12)

project(net-common)

file(GLOB_RECURSE ALL_SOURCE "*.cpp" "*.c")

MESSAGE(STATUS ${ALL_SOURCE})

function(include_sub_directories_recursively root_dir)
    if (IS_DIRECTORY ${root_dir})
        message(STATUS "include dir: " ${root_dir})
        target_include_directories(${PROJECT_NAME} INTERFACE ${root_dir})
    endif()
    file(GLOB ALL_SUB RELATIVE ${root_dir} ${root_dir}/*)
    foreach(sub ${ALL_SUB})
        if (IS_DIRECTORY ${root_dir}/${sub})
            include_sub_directories_recursively(${root_dir}/${sub})
        endif()
    endforeach()
endfunction()

add_library(${PROJECT_NAME} SHARED ${ALL_SOURCE})

include_sub_directories_recursively(${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(${PROJECT_NAME} PUBLIC csapp)